import java.awt.Color;
import java.awt.Font;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.BarRenderer;

import net.sf.jasperreports.engine.JRAbstractChartCustomizer;
import net.sf.jasperreports.engine.JRChart;


public class BarCustomizer extends JRAbstractChartCustomizer

{
 
    public void customize(JFreeChart chart, JRChart jasperChart) {
          
     //Chart is a bar chart
     if(jasperChart.getChartType() == JRChart.CHART_TYPE_BAR) {
           
            BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();
                
            //Remove shadow effect from bar
            renderer.setShadowVisible(false);
            
            renderer.setSeriesPaint(0, Color.pink);
           
            //Set maximum bar width
            renderer.setMaximumBarWidth(0.80);
            
            renderer.setMaximumBarWidth(0.80);
           
           //Create no data message
            CategoryPlot categoryplot = (CategoryPlot) chart.getCategoryPlot();
           
            categoryplot.setNoDataMessage("No data available");
            categoryplot.setNoDataMessageFont(new Font("SansSerif",Font.BOLD,14));
            categoryplot.setNoDataMessagePaint(Color.WHITE);
           
            //Set background as transparent
            categoryplot.setBackgroundPaint(null);
                                   
            //Set left margin before first bar and right margin after last bar

     }         
    }
}